package com.bjqh.edu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bjqh.edu.Base.AppConstants;
import com.bjqh.edu.Bean.Room;
import com.bjqh.edu.R;
import com.bjqh.edu.Widget.CircleImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/10/18.
 */

public class PendingAdapter extends BaseAdapter {
    private List<Room.DataBean> list;
    private Context ctx;
    private ViewHolder holder;

    public PendingAdapter(Context ctx, List<Room.DataBean> list) {
        this.ctx = ctx;
        this.list = list;

    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = LayoutInflater.from(ctx).inflate(R.layout.item_pending, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tvName.setText(list.get(i).getName());
        holder.tvRname.setText(list.get(i).getRname());
        holder.tvRid.setVisibility(View.GONE);
        Glide.with(ctx)
                .load(AppConstants.IMG_URL + list.get(i).getHeader())
                .error(R.mipmap.tx)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(holder.cv);
        return view;
    }



    static class ViewHolder {
        @BindView(R.id.cv)
        CircleImageView cv;
        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.tv_rid)
        TextView tvRid;
        @BindView(R.id.tv_rname)
        TextView tvRname;
        @BindView(R.id.tv_ok)
        TextView tvOk;


        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }


}
